cmake_minimum_required(VERSION 3.20)

project(AMath VERSION 0.1.1)

# 添加目标
add_subdirectory(AMath)
# 安装导出集AMathLibrary中的<导出集文件名>.cmake配置文件
install(EXPORT AMathLibrary FILE AMathLibrary.cmake DESTINATION lib/cmake/AMath)
include(CMakePackageConfigHelpers)

# generate the config file that includes the exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in
  "${CMAKE_CURRENT_BINARY_DIR}/AMathConfig.cmake"
  INSTALL_DESTINATION "lib/cmake"
  NO_SET_AND_CHECK_MACRO
  NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

write_basic_package_version_file(
  "${CMAKE_CURRENT_BINARY_DIR}/AMathConfigVersion.cmake"
  VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
  COMPATIBILITY AnyNewerVersion
)

# 安装生成文件
install(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/AMathConfig.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/AMathConfigVersion.cmake
  DESTINATION lib/cmake/AMath
)
